const Koa=require('koa2');
const path=require('path');
const static=require('koa-static');
const Router = require('koa-router')
const router = new Router()
const bodyParser=require('koa-bodyparser');
const conf=require('./mongoose/conf.js');
const wechat=require('co-wechat');
const app=new Koa();
app.use(bodyParser());
//静态资源目录入口
const staticPath='./dist';
app.use(static(path.join(__dirname,staticPath)));
router.get('/getdata',async ctx=>{
    ctx.body='hello world111'
})
router.all('/wechat', wechat(conf).middleware(
    async message => {
        console.log('wechat:', message)
        return 'Hello World ' + message.Content
    }
))
app.use(async ctx=>{
    ctx.body='hello world22221'
})
app.use(router.routes());  // 添加路由中间件
app.use(router.allowedMethods()); // 对请求进行一些限制处理
app.listen(4000,()=>{
    console.log('port 4000')
})
